/**
 * Created by bolin on 2016/4/26.
 */
package team.zero.lemon.common.persistence;

import org.apache.ibatis.annotations.Param;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;

import java.util.Date;
import java.util.List;

/**
 * DAO支持类实现
 *
 * @param <T>
 * @author bolin
 * @version 2014-05-16
 */
public interface ICrudDao<T> extends IBaseDao {

    /**
     * 获取单条数据
     *
     * @param id
     * @return
     */
    @Cacheable(value = "mybatisEhcache")
    public T findById(@Param("id") int id);

    /**
     * 查询数据列表
     *
     * @param entity
     * @return
     */
    @Cacheable(value = "mybatisEhcache")
    public List<T> findList(T entity);

    /**
     * 分页查询数据列表
     *
     * @param entity
     * @return
     */
    public List<T> findPage(T entity);

    /**
     * 查询所有数据列表
     *
     * @return
     * @see public List<T> findAllList(T entity)
     */
    @Deprecated
    @Cacheable(value = "mybatisEhcache")
    public List<T> findAll();

    /**
     * 插入数据
     *
     * @param entity
     * @return
     */
    @CacheEvict(value = "mybatisEhcache", allEntries = true)
    public int insert(T entity);

    /**
     * 插入数据
     *
     * @param entity
     * @return
     */
    @CacheEvict(value = "mybatisEhcache", allEntries = true)
    public int insertWithKey(T entity);

    /**
     * 插入数据
     *
     * @param entitys
     * @return
     */
    @CacheEvict(value = "mybatisEhcache", allEntries = true)
    public int insert(List<T> entitys);

    /**
     * 更新数据
     *
     * @param entity
     * @return
     */
    @CacheEvict(value = "mybatisEhcache", allEntries = true)
    public int update(T entity);

    /**
     * 删除数据
     *
     * @param id
     * @return
     * @see public int delete(T entity)
     */
    @Deprecated
    @CacheEvict(value = "mybatisEhcache", allEntries = true)
    public int delete(@Param("id") int id);

    /**
     * 逻辑删除，更新isDel字段为1）
     *
     * @param entity
     * @return
     * @see public int delete(T entity)
     */
    @Deprecated
    @CacheEvict(value = "mybatisEhcache", allEntries = true)
    public int deleteLogic(T entity);

    /**
     * 删除数据
     *
     * @param ids
     * @return
     * @see public int deleteMulti(T entity)
     */
    @Deprecated
    @CacheEvict(value = "mybatisEhcache", allEntries = true)
    public int deleteMulti(@Param("ids") List<Integer> ids);

    /**
     * 逻辑删除，更新isDel字段为1）
     *
     * @param entity
     * @return
     * @see public int deleteMulti(T entity)
     */
    @Deprecated
    @CacheEvict(value = "mybatisEhcache", allEntries = true)
    public int deleteLogicMulti(T entity);
}